﻿using System.Windows;
using System.Windows.Controls;

namespace FrontDisplay.Power
{
    public class PowerPlugin : PluginBase
    {
        private PowerPage _powerPage;
        private readonly Label _menuButton;
        private Hotkey _hotkey;

        public PowerPlugin()
        {
            _menuButton = new Label
            {
                //TODO: store resource as embedded resource (or investigate for better solution).
                Content = new Image { Source = Utility.LoadBitmap(Properties.Resources.Power) },
                Padding = new Thickness(30, 0, 30, 0)
            };
        }

        public override string Title
        {
            get { return Def.Localization.GetString("Power.Power"); }
        }

        public override void Start()
        {
            _hotkey = new Hotkey(new HotkeyInfo { Win = true, Shift = true, Key = System.Windows.Input.Key.P })
            {
                Action = () => { Navigation.Navigate(PageControl); Application.Current.MainWindow.Activate(); }
            };
            _hotkey.Register(Application.Current.MainWindow);
        }

        public override void Stop()
        {
            if (_hotkey != null) _hotkey.Unregister();
        }

        public override UIElement MenuButton
        {
            get
            {
                return _menuButton;
            }
        }

        public override Control PageControl
        {
            get
            {
                if (_powerPage == null)
                {
                    _powerPage = new PowerPage();
                }
                return _powerPage;
            }
        }

        public override UIElement TopControl
        {
            get { return null; }
        }

        public override UIElement BottomControl
        {
            get { return null; }
        }

        public override UIElement ParametersControl
        {
            get { return null; }
        }
    }
}
